package com.apestech.api.xml.core;

import com.apestech.framework.db.SqlSession;
import com.apestech.framework.json.JSONArray;
import com.apestech.framework.json.JSONObject;
import com.apestech.framework.run.datamapper.SingleDataMappingModule;

import java.util.ArrayList;

/**
 * 定义结点
 *
 * @author hup
 * @create 2018-04-20-16:47
 */
public class Define {

    private JSONObject input;
    private ArrayList<SingleDataMappingModule> output;
    private String queryId;
    private SqlSession session;
    private boolean hasData;

    public Define(String queryId){
        this.queryId=queryId;
    }

    public void setSession(SqlSession session){
        this.session=session;
    }

    public void setInput(JSONObject input){
        this.input=input;
    }

    public void execute() throws Exception {
        JSONArray list=session.getForJSON().queryId(this.queryId, this.input);
        this.hasData=(list.size()>0);
        //this.output.put("list", list);
    }

    public ArrayList<SingleDataMappingModule> getOutput(){
        return this.output;
    }

    public boolean getHasData(){
        return this.hasData;
    }

}
